


<template>
    <div class="model-form">
        <el-page-header @back="goBack" content="增加客户">
        </el-page-header>
        <div class="model-content">
            <el-form ref="ruleForm" :rules="rules" :model="form" label-width="160px">
                <el-row :gutter="10">
    <el-col :span="12">
            <el-form-item label="客户名称"  prop="name">
        <el-input v-model="form.name" name="name">
        </el-input>
            </el-form-item>

    </el-col>
    <el-col :span="12">
            <el-form-item label="客户名称"  prop="nickName">
        <el-input v-model="form.nickName" name="nickName">
        </el-input>
            </el-form-item>

    </el-col>
    <el-col :span="12">
            <el-form-item label="真实姓名"  prop="realName">
        <el-input v-model="form.realName" name="realName">
        </el-input>
            </el-form-item>

    </el-col>
    <el-col :span="12">
            <el-form-item label="联系电话"  prop="phone">
        <el-input v-model="form.phone" name="phone">
        </el-input>
            </el-form-item>

    </el-col>
    <el-col :span="12">
            <el-form-item label="客户分组"  prop="customerGroup">
        <el-select style="width: 100%;" v-model="form.customerGroup" filterable clearable
                   placeholder="请选择">
            <el-option v-for="item in customerGroupOptions" :key="item.id"
                       :label="item.name" :value="item.id">
            </el-option>
        </el-select>
            </el-form-item>

    </el-col>
    <el-col :span="12">
            <el-form-item label="客户等级"  prop="customerLevel">
        <el-select style="width: 100%;" v-model="form.customerLevel" filterable clearable
                   placeholder="请选择">
            <el-option v-for="item in customerLevelOptions" :key="item.id"
                       :label="item.name" :value="item.id">
            </el-option>
        </el-select>
            </el-form-item>

    </el-col>

                    <el-col :span="22">
                        <el-form-item>
                            <el-button @click="goBack">取消</el-button>
                            <el-button type="primary" @click="createData">确定</el-button>
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
        </div>
    </div>
</template>

<script setup>
        import nbSelect from "@/components/nbSelect.vue";
    import {ref} from "vue";
    import {useData} from "@/utils/useData";
    import {useCreate} from "@/uses/useCreate";

    const form = ref({
         name: null ,
         nickName: null ,
         realName: null ,
         phone: null ,
         customerGroup: null ,
         customerLevel: null     })

    const rules = ref({
       name: [
           {required: true, message: '请输入客户名称', trigger: 'blur'}
       ],
    })

    const ruleForm = ref(null);
    const{listData:customerGroupOptions}= useData("/customerGroup/list")
    const{listData:customerLevelOptions}= useData("/customerLevel/list")

    const {createData,goBack} =useCreate("customer",form,ruleForm)

</script>

<style scoped>
</style>